<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    </style>
</head>

<body>
       <input id="ccc" type="radio" onclick="fn()" value="男" checked name="xb"><label for="ccc" >男</label>
       <input id="ddd" type="radio" onclick="fn()" value="女" name="xb"><label for="ddd">女</label>
    <script>
    function  fn(){
        var ipt =Array.from(document.querySelectorAll('input'))
        ipt.forEach(item=>{
            if(item.checked){
                console.log(item.value,'获取到的状态值');
            }
        })
    }
    </script>
</body>
</html>